/**
 * 提现状态
 */

export const state = () => {
  let form = sessionStorage.getItem("wealth-recharge-form");

  try {
      form = JSON.parse(form);
  } catch (e) {
    sessionStorage.removeItem("wealth-recharge-form");
    form = null;
  }


  return {
    form, //表单
  }
}

export const mutations = {
  setForm(state, form) {
    if (form) {
      sessionStorage.setItem("wealth-recharge-form", JSON.stringify(form));
    } else {
      sessionStorage.removeItem("wealth-recharge-form");
    }
    state.form = form || null
  },
}

export const actions = {
  clear({
    commit
  }) {
    // 清楚所有状态
    commit('setForm', null)
  },
}
